<template>
  <view class="padding-lr bg-white">
    <view class="cell text-cut" v-for="i in member" :key="i.id">
      <u-avatar class="margin-right-sm" :src="i.member.portrait" size="64" :show-level="i.manager > 0"
        level-icon="account-fill" :level-bg-color="i.manager == 2 ? '#ffc707' : '#1268fd'"></u-avatar>
      <text class="name text-cut">{{i.member.nickname}}</text>
      <view class="btns flex-row justify-around align-center" style="width: 240rpx;">
        <my-btn width="100" height="50" inline size="24" @click="handle(i.member_id, 1)">同意</my-btn>
        <my-btn width="100" height="50" bg-color="linear-gradient(to left, #536976, #292E49)" inline size="24" @click="handle(i.member_id, 2)">拒绝</my-btn>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        id: '',
        member: []
      };
    },
    onLoad(opt) {
      this.id = opt.id
      this.getAudit()
    },
    methods: {
      async getAudit() {
        let res = await this.$u.get('/company/member/audit?id=' + this.id)
        let {
          msg,
          result
        } = res.data
        let {
          member
        } = result
        this.member = member
      },
      async handle(id, type) {
        let params = {
          id: this.id,
          member_id: id,
          type: type
        }
        let res = await this.$u.post('/company/member/audit/process', params)
        let { msg, result } = res.data
        this.$msg(msg)
        this.getAudit()
      }
    }
  }
</script>

<style lang="scss">
  .cell {
    width: 100%;
    height: 90rpx;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    font-size: 30rpx;
    letter-spacing: 1px;
    color: #333333;
    
    .name {
      width: 360rpx;
    }
  }
</style>
